home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / get_dr1r / tv.frm < prev    next >
Text File  |  1999-06-29  |  5KB  |  133 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   0  'None
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   150
  7.    ClientTop       =   435
  8.    ClientWidth     =   4680
  9.    Icon            =   "TV.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   213
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   312
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.Timer Timer1 
  17.       Interval        =   10
  18.       Left            =   960
  19.       Top             =   2640
  20.    End
  21.    Begin VB.PictureBox Picture1 
  22.       AutoSize        =   -1  'True
  23.       Height          =   645
  24.       Left            =   2040
  25.       Picture         =   "TV.frx":0442
  26.       ScaleHeight     =   585
  27.       ScaleWidth      =   2235
  28.       TabIndex        =   0
  29.       Top             =   1320
  30.       Width           =   2295
  31.    End
  32. End
  33. Attribute VB_Name = "Form1"
  34. Attribute VB_GlobalNameSpace = False
  35. Attribute VB_Creatable = False
  36. Attribute VB_PredeclaredId = True
  37. Attribute VB_Exposed = False
  38.  
  39.  
  40. Private Sub Form_Load()
  41.    'add to system tray
  42.    With nidProgramData
  43.         .cbSize = Len(nidProgramData)
  44.         .hwnd = Form1.hwnd
  45.         .uId = vbNull
  46.         .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
  47.         .uCallbackMessage = WM_MOUSEMOVE
  48.         .hIcon = Form1.Icon
  49.         .szTip = "We're On TV" & vbNullChar
  50.     End With
  51.     
  52.   Shell_NotifyIcon NIM_ADD, nidProgramData
  53.   
  54.   oldfocus = GetForegroundWindow()             ' get currently active window
  55.   
  56.   frmx = Screen.Width / Screen.TwipsPerPixelX - (Picture1.Width / 1.5)    ' calculate screen positions
  57.   frmy = 0
  58.   
  59.   'set form1 to be top window
  60.   tmpval = SetWindowPos(Form1.hwnd, HWND_NOTOPMOST, frmx, frmy, Picture1.Width, Picture1.Height, SWP_SHOWME)
  61.   
  62.   'set variables
  63.   angle_x = 0 'logo x angle
  64.   angle_y = 0 'logo y angle
  65.   speed = 5    'spin speed
  66.   i = 0               'general dogs body variable... ;)
  67.    
  68.   screendc = CreateDC("DISPLAY", "", "", 0&) 'get screen device context
  69.      
  70.   LogoDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height) 'create work areas for logo
  71.   BackDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height)
  72.   StageDC = NewDC(Form1.hDC, Picture1.Width, Picture1.Height)
  73.     
  74.   tmpval = SelectObject(LogoDC, Picture1) ' copy logo
  75.   tmpval = BitBlt(BackDC, 0, 0, Picture1.Width, Picture1.Height, screendc, frmx, frmy, SRCCOPY) ' set background of work area
  76.        
  77.   'for use later when setting window visible but not active
  78.   currWinP.Length = Len(currWinP)
  79.   currWinP.flags = 0&
  80.   currWinP.showCmd = SW_SHOWNOACTIVATE
  81.        
  82.   Form1.Hide   ' hide form1
  83.   winvis = False   'form1 hidden
  84. End Sub
  85.  
  86. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  87.       If X = WM_RBUTTONUP Then  ' was the r-button clicked on system tray
  88.         Form1.PopupMenu Form2.mnu_shell 'Yep, display popup menu
  89.      End If
  90. End Sub
  91.  
  92. Private Sub Timer1_Timer()
  93.  
  94.     tmpval = GetCursorPos(mouse)   'get mouse position
  95.     curfocus = GetForegroundWindow()    ' get currently active window
  96.  
  97.     If (mouse.X > frmx And mouse.Y < Picture1.Height) Or (curfocus <> oldfocus) Then      'is the mouse on the form or has the active window changed????
  98.         oldfocus = curfocus   ' update old active window
  99.         If winvis = True Then    ' if were displaying then ....
  100.             currWinP.showCmd = SW_HIDE         ' set window to hide
  101.             tmpval = SetWindowPlacement(Form1.hwnd, currWinP)    ' hide window
  102.             winvis = False    ' window hidden
  103.         End If
  104.     Else
  105.         If mouse.X < frmx Or mouse.Y > frmy + Picture1.Height Then  ' is mouse on form1?
  106.             If winvis = False Then ' is form1 hidden?
  107.                 tmpval = BitBlt(BackDC, 0, 0, Picture1.Width, Picture1.Height, screendc, frmx, frmy, SRCCOPY) 'as form1 is hidden grab screen
  108.                 currWinP.showCmd = SW_SHOWNOACTIVATE ' set form1 to show but not activate
  109.                 tmpval = SetWindowPlacement(Form1.hwnd, currWinP) 'send to form1
  110.                 tmpval = SetWindowPos(Form1.hwnd, HWND_TOPMOST, frmx, frmy, Picture1.Width, Picture1.Height, SWP_SHOWME) ' show form1
  111.                 winvis = True 'form1 visible
  112.             End If
  113.         End If
  114.    
  115.         tmpval = BitBlt(StageDC, 0, 0, Picture1.Width, Picture1.Height, BackDC, 0, 0, SRCCOPY) 'copy background to stage area
  116.         
  117.         For i = Form1.Picture1.Width To 1 Step -1
  118.             tmpval = BitBlt(StageDC, Cos(degtorad(angle_x + i)) * (Picture1.Width / 3.2) + (Picture1.Width / 3.2), Sin(degtorad(angle_y + i)) * (5) + 2.5, 1, Picture1.Height, LogoDC, i, 0, SRCAND) ' put spinning logo onto stage area
  119.         Next i
  120.         tmpval = BitBlt(Form1.hDC, 0, 0, Picture1.Width, Picture1.Height, StageDC, 0, 0, SRCCOPY) ' copy stage to form1
  121.         
  122.         angle_x = angle_x + speed ' rotate logo x
  123.         angle_y = angle_y + speed ' rotate logo y
  124.         
  125.         If angle_x >= 360 Then  ' have we done a full rotation 360o??
  126.             angle_x = 0  ' Yep, reset angle
  127.         End If
  128.         If angle_y >= 360 Then
  129.             angle_y = 0
  130.         End If
  131.     End If
  132. End Sub
  133.